Entering text in EMACS is simple. Type the following sentence fragment:
Fang Rock lighthouse, center of a series of mysterious and
The text is displayed at the top of the text window. Now type:
terrifying events at the turn of the century
Notice that some of your text has dissapeared off the left side of the
screen. Don't panic--your text is safe!!! You've just discovered that EMACS
2 Basic Concepts MicroEMACS Reference Manual
doesn't "wrap" text to the next line like most word processors unless you hit
<NL>. But since EMACS is used for both word processing, and text editing, it has
a bit of a dual personality. You can change the way it works by setting various
modes. In this case, you need to set WRAP mode, using the add-mode command, by modes WRAP ________
typing ^XM. The command line at the base of the screen will prompt you for the ^XM
mode you wish to add. Type wrap followed by the <NL> key and any text you now wrap
enter will be wrapped. However, the command doesn't wrap text already entered.
To get rid of the long line, press and hold down the <BACKSPACE> key until the
line is gone. Now type in the words you deleted, watch how EMACS goes down to
the next line at the right time. (In some versions of EMACS, WRAP is a default ___ ____ ________ __ ______ WRAP __ _ _______ ____
mode in which case you don't have to worry about the instructions relating to ____ __ _____ ____ ___ _____ ____ __ _____ _____ ___ ____________ ________ __
adding this mode.) ______ ____ ______
Now let's type a longer insert. Hit <NL> a couple of times to tab down
from the text you just entered. Now type the following paragraphs. Press <NL>
twice to indicate a paragraph break.
Fang Rock lighthouse, center of a series of mysterious and terrifying
events at the turn of the century, is built on a rocky island a few
miles of the Channel coast. So small is the island that wherever you
stand its rocks are wet with sea spray.
The lighthouse tower is in the center of the island. A steep flight of
steps leads to the heavy door in its base. Winding stairs lead up to
the crew room.
1.5 Basic cursor movement 1.5 Basic cursor movement
Now let's practice moving around in this text. To move the cursor back
to the word "Winding," enter M-B previous-word. This command moves the cursor M-B _____________
backwards by one word at a time. Note you have to press the key combination
every time the cursor steps back by one word. Continuously pressing META and
toggling B produces an error message. To move forward to the word "stairs" enter
M-F next-word, which moves the cursor forward by one word at a time. M-F _________
Notice that EMACS commands are usually mnemonic--F for forward, B for
backward, for example.
To move the cursor up one line, enter ^P previous-line, down one line ^N ^P _____________ ^N
next-line. Practice this movement by moving the cursor to the word "terrifying" _________
in the second line.
The cursor may also be moved forward or backward in smaller increments.
To move forward by one character, enter ^F forward-character, to move backward, ^F _________________
^B backward-character. EMACS also allows you to specify a number which is ^B __________________
normally used to tell a command to execute many times. To repeat most commands,
press META and then the number before you enter the command. Thus, the command
META 5 ^F (M-5^F) will move the cursor forward by five characters. Try moving M-5^F
around in the text by using these commands. For extra practice, see how close
3 MicroEMACS Reference Manual Basic Concepts
you can come to the word "small" in the first paragraph by giving an argument to
the commands listed here.
Two other simple cursor commands that are useful to help us move around
in the text are M-N next-paragraph which moves the cursor to the second M-N ______________
paragraph, and M-P previous-paragraph which moves it back to the previous M-P __________________
paragraph. The cursor may also be moved rapidly from one end of the line to the
other. Move the cursor to the word "few" in the second line. Press ^A beginning- ^A __________
of-line. Notice the cursor moves to the word "events" at the beginning of the _______
line. Pressing ^E end-of-line moves the cursor to the end of the line. ^E ___________
Finally, the cursor may be moved from any point in the file to the end
or beginning of the file. Entering M-> end-of-file moves the cursor to the end M-> ___________
of the buffer, M-< beginning-of-file to the first character of the file. M-< _________________
On the IBM-PC, the ATARI ST and many other machines, the cursor keys can __ ___ _______ ___ _____ __ ___ ____ _____ _________ ___ ______ ____ ___
also be used to move the cursor. ____ __ ____ __ ____ ___ _______
Practice moving the cursor in the text until you are comfortable with
the commands we've explored in this chapter.
1.6 Saving your text 1.6 Saving your text
When you've finished practicing cursor movement, save your file. Your
file currently resides in a BUFFER. The buffer is a temporary storage area for BUFFER
your text, and is lost when the computer is turned off. You can save the buffer
to a file by entering ^X^S save-file. Notice that EMACS informs you that your ^X^S _________
file has no name and will not let you save it.
To save your buffer to a file with a different name than it's current
one (which is empty), press ^X^W write-file. EMACS will prompt you for the ^X^W __________
filename you wish to write. Enter the name fang.txt and press return. On a fang.txt
micro, the drive light will come on, and EMACS will inform you it is writing the
file. When it finishes, it will inform you of the number of lines it has written
to the disk.
Congratulations!! You've just saved your first EMACS file!
4 Basic Concepts MicroEMACS Reference Manual
Chapter 1 Summary Chapter 1 Summary
In chapter 1, you learned how to enter text, how to use wrap mode, how
to move the cursor, and to save a buffer. The following is a table of the
commands covered in this chapter and their corresponding key bindings:
The number insided the brackets [] shows that the screen is now scrolled
12 characters from the left margin.
Now grab the same text again, and drag it to the right, pulling the rest
of the text back into the current window. The [<] field will disappear, meaning
that the window is no longer scrolled to the left. This feature is very useful
for looking at wide charts and tables. Remember, MicroEMACS will only scroll
the text in the current window sideways if you drag it straight to the side,
otherwise it will drag the text vertically.
Now, place the mouse cursor over a character on the upper mode line,
click down, move the mouse cursor up or down a few lines and let go of the
button. The mode line moves to where you dragged it, changing the size of the
windows above and below it. If you try to make a window with less than one line,
EMACS will not let you. Dragging the mode lines can make it very fast and easy
for you to rearrange the windows as you would like.
If you have a number of different windows visible on the screen,
positioning the mouse over the mode line of one window and clicking the right
mouse button will cause that window to be deleted.
6.3 Cut and Paste 6.3 Cut and Paste
If your mouse has two buttons, then you can use the right button to do
some other things as well. Earlier, we learned how to define a region by using region
the M-<space> set-mark command. Now, position the mouse over at the beginning of M-<space> ________
a region you would like to copy. Next click and hold down the right mouse
button. Notice that the point jumps to the mouse cursor and EMACS reports "[Mark
Set]". Holding the button down move the mouse to the end of the text you wish to
copy and release the mouse button. Emacs reports "[Region Copied]" to let you
know it has copied the region into the KILL buffer. This has done the same job
as the M-W copy-region command. M-W ___________
If you now click the right mouse button, without moving the mouse, the
region you defined dissapear, being cut from the current buffer. This works just cut
like the ^W kill-region command. ^W ___________
22 Using a Mouse MicroEMACS Reference Manual
If you move the mouse away from where you cut the text, and click the
right mouse button down and up without moving the mouse, the text in the KILL
buffer gets inserted, or pasted into the current buffer at the point.
6.4 Screens 6.4 Screens
MicroEMACS can use more than one screen at once. Each screen is a
collection of windows along with a mode line. These screens usually fill the _______
terminal or computer screen on text based systems, but can also be held in
different windows on graphically based systems like MicroSoft Windows, OS/2, the windows
Macintosh Finder and X-Windows. Don't be confused by the two different uses of
the term "window". Inside EMACS style editors, a window lets you view part of a ______
buffer. Under graphical operating systems, a window holds a "virtual terminal", window
allowing you to manipulate more than one job, editing session or program at
once. Within MicroEMACS, these operating system windows are called screens. All window
these screens are displayed on your current desktop.
6.5 Resizing a Screen 6.5 Resizing a Screen
You can change the size of a screen. Move the mouse to the last position
of the command line. Press the left mouse button down. Holding it, move the
mouse to the place you want the new lower right corner. Release the mouse. The
desktop redraws, with your newly resized screen. MicroEMACS will ignore size
changes that can not be done, like attempting to pull the lower left corner
above the upper right corner of the current screen.
6.6 Moving a Screen 6.6 Moving a Screen
To change where on the desktop a screen is placed, move the mouse to the
upper right corner of the screen, press the left mouse button down, move the
mouse and release it where you want the screen displayed. Again, MicroEMACS will
ignore placements that can not be done.
6.7 Creating a Screen 6.7 Creating a Screen
Creating a new screen is just like moving a screen, but using the right
button. Move to the upper right of an existing screen, press the right mouse
button down, and move the mouse, releasing the button where the new screen
should appear. A new screen will have a single window, containing the contents window
of the current window in the copied screen, and will have that window's colors. window
The new screen will have the copied screen's size.
6.8 Switching to a Screen 6.8 Switching to a Screen
This is simple. Any mouse command can be done in any screen by placing
the mouse on a visible part of the screen and clicking. The last screen the
23 MicroEMACS Reference Manual Using a Mouse
mouse is used on comes to front and is the current screen. Also, the A-C cycle- A-C ______
screens command brings the rearmost screen to front. _______
6.9 Deleting a Screen 6.9 Deleting a Screen
Place the mouse on the command line of the screen you want to delete.
Click the right mouse button, the screen will disapear. If you delete the only
remaining screen on the desktop, MicroEMACS will exit.
24 Using a Mouse MicroEMACS Reference Manual
Chapter 6 Summary Chapter 6 Summary
In Chapter 6, you learned how to use the mouse to move the point, switch
windows, drag text, and resize windows. You also learned how to use the right
mouse button in order to copy and delete regions and yank them back at other
places. And lastly, you learned how to control multiple screens with the mouse.
25 MicroEMACS Reference Manual Using a Mouse
Action Mouse Directions ______ _____ __________
Move Cursor position mouse cursor over desired location
click down and up with left button
Drag Text position mouse cursor over desired text
click left button down
move to new screen location for text
release mouse button
Resize Windows position mouse cursor over mode line to move
click left button down
move to new location for mode line
release mouse button
Delete Window position mouse cursor over mode line of window to delete
click right mouse button
Activate Screen Move mouse over existing screen
click left button down and up
Resize Screen position mouse cursor over last character on message line
click left button down
move to new lower right corner of screen
release mouse button
Copy Region position mouse at beginning of region
click right button down
move to end of region
release mouse button
Cut Region position mouse at beginning of region
click right button down
move to end of region
release mouse button
click right button down and up
Paste Region position mouse at place to paste
click right button down and up
Create Screen position mouse at upper left corner of existing screen
click right button down
move to position of new screen
release mouse button
Resize Screen position mouse at lower right corner of screen
click left button down
move to new lower left corner
release mouse button
Move Screen position mouse at upper right corner of screen
26 Buffers MicroEMACS Reference Manual
click left button down
move to new screen position
release mouse button
Delete Screen position to command line of existing screen
click right button down
release mouse button
Chapter 7 Chapter 7
Buffers Buffers
We have already learned a number of things about buffers. As you will
recall, they are the major internal entities in EMACS -- the place where editing
commands are executed. They are characterized by their names, their modes, and names modes
by the file with which they are associated. Each buffer also "remembers" its
mark and point. This convenient feature allows you to go to other buffers and mark point
return to the original location in the "current" buffer.
Advanced users of EMACS frequently have a number of buffers in the
computer's memory simultaneously. In the last chapter, for example, you opened
at least two buffers -- one into the text you were editing, and the other into
the EMACS on-line tutorial. If you deal with complex text files -- say,
sectioned chapters of a book, you may have five or six buffers in the computer's
memory. You could select different buffers by simply calling up the file with
^X^F find-file, and let EMACS open or reopen the buffer. However, EMACS offers ^X^F _________
fast and sophisticated buffering techniques that you will find easy to master
and much more convenient to use.
Let's begin by opening three buffers. You can open any three you choose,
for example call the following files into memory: fang.txt, publish.txt, and fang.txt publish.txt
emacs.tut in the order listed here. When you've finished this process, you'll be emacs.tut
looking at a screen showing the EMACS tutorial. Let's assume that you want to
move to the fang.txt buffer. Enter:
^XX next-buffer ^XX ___________
This command moves you to the next buffer. Because EMACS cycles through ____
the buffer list, which is alphabetized, you will now be in the fang.txt buffer. fang.txt
Using ^XX again places you in the publish.txt buffer. If you are on a machine ^XX publish.txt __ ___ ___ __ _ _______
that supports function keys, using ^XX again places you in the Function Keys ____ ________ ________ _____ _____ ^XX _____ ______ ___ __ ___ Function Keys ___ ________ ____
buffer. Using ^XX one last time cycles you back to the beginning of the list. ______ ^XX
If you have a large number of buffers to deal with, this cycling process
may be slow and inconvenient. The command ^XB select-buffer allows you to ^XB _____________
specify the buffer you wish to be switched to. When the command is entered,
EMACS prompts, "Use buffer:". Simply enter the buffer name (NOT the file name),
27 MicroEMACS Reference Manual Buffers
and that buffer will then become the current buffer. If you type in part of the
file name and press the space bar, EMACS will attempt to complete the name from
the list of current buffers. If it succeeds, it will print the rest of the name
and you can hit <NL> to switch to that buffer. If EMACS beeps the bell, there is
no such buffer, and you may continue editing the name on the command line.
Multiple buffer manipulation and editing is a complex activity, and you
will probably find it very inconvenient to re-save each buffer as you modify it.
The command ^X^B list-buffers creates a new window that gives details about all ^X^B ____________
the buffers currently known to EMACS. Buffers that have been modified are
identified by the "buffer changed" indicator (an asterisk in the second column).
You can thus quickly and easily identify buffers that need to be saved to files
before you exit EMACS. The buffer window also provides other information --
buffer specific modes, buffer size, and buffer name are also listed. To close
this window, simply type the close-windows command, ^X1. ^X1
To delete any buffer, type ^XK delete-buffer. EMACS prompts you "Kill ^XK _____________
buffer:". Enter the buffer name you want to delete. As this is destructive
command, EMACS will ask for confirmation if the buffer was changed and not
saved. Answer Y(es) or N(o). As usual ^G cancels the command. ^G
28 Buffers MicroEMACS Reference Manual
Chapter 7 Summary Chapter 7 Summary
In Chapter 7 you learned how to manipulate buffers.
add-mode/WRAP ^XM[WRAP] Add wrap mode to current buffer ^XM
delete-mode/WRAP ^X^M[WRAP] Remove wrap mode from current buffer ^X^M
set-fill-column ^XF Set fill column to given numeric ^XF
argument
fill-paragraph M-Q Logically reformats the current M-Q
paragraph
case-word-upper M-U Text from point to end of the M-U
current word is changed to uppercase
case-word-lower M-L Text from point to end of the M-L
current word is changed to lowercase
case-word-capitalize M-C First word (or letter) after the M-C
point is capitalized
case-region-upper ^X^U The current region is uppercased ^X^U
case-region-lower ^X^L The current region is lowercased ^X^L
handle-tab ^I Tab interval is set to the given ^I
numeric argument
entab-region ^X^E Changes multiple spaces to tabs ^X^E
characters where possible
detab-region ^X^D Changes tab characters to the ^X^D
appropriate number of spaces
trim-region ^X^T Trims white space from the end ^X^T
of the lines in the current region
42 Access to the Outside World MicroEMACS Reference Manual
Chapter 11 Chapter 11
Access to the Outside World Access to the Outside World
EMACS has the ability to interface to other programs and the environment
of the computer outside of itself. It does this through a series of commands
that allow it to talk to the computer's command processor or shell. Just what command processor shell
this is varies between different computers. Under MSDOS or PCDOS this is the
command.com command processor. Under UNIX it is the csh shell. On the Atari ST command.com csh
is can be the Mark Williams MSH or the Beckmeyer shell. In each case, it is the MSH
part of the computer's operating system that is responsible for determining what
programs are executed, and when.
The ^X! shell-command command prompts the user for a command line to ^X! _____________
send out to the shell to execute. This can be very useful for doing file
listings and changing the current directory or folder. EMACS gives control to
the shell, which executed the command, and then types [END] and waits for the [END]
user to type a character before redrawing the screen and resuming editing. If
the shell-command command is used from within the macro language, there is no _____________
pause.
^X@ pipe-command command allows EMACS to execute a shell command, and if ^X@ ____________
the particular computer allows it, send the results into a buffer which is
automatically displayed on the screen. The resulting buffer, called "command"
can be manipulated just like any other editing buffer. Text can be copied out of
it or rearranged as needed. This buffer is originally created in VIEW mode, so VIEW
remember to ^X^Mview<NL> in order to change it. ^X^Mview<NL>
Many computers provide tools which will allow you to filter text, making filter
some modifications to it along the way. A very common tool is the SORT program SORT
which accepts a file, sorts it, and prints the result out. The EMACS command,
^X# filter-buffer sends the current buffer through such a filter. Therefore, if ^X# _____________
you wished to sort the current buffer on a system which supplied a sort filter,
you would type ^X#sort<NL>. You can also create your own filters by writing ^X#sort<NL>
programs and utilities which read text from the keyboard and display the
results. EMACS will use any of these which would normally be available from the
current shell.
If you would like to execute another program directly, without the
overhead of an intervening shell, you can use the ^X$ execute-program command. ^X$ _______________
It will prompt you for an external program and its arguments and attempt to
execute it. Like when EMACS looks for command files, EMACS will look first in
the HOME directory, then down the execute PATH, and finally in the current
directory for the named program. On some systems, it will automatically tack the
proper extension on the file name to indicate it is a program. On some systems
that don't support this function, ^X$ will be equivalent to ^X! shell-command. ^X$ ^X! _____________
43 MicroEMACS Reference Manual Access to the Outside World
Sometimes, you would like to get back to the shell and execute other
commands, without losing the current contents of EMACS. The ^XC i-shell command ^XC _______
shells out of EMACS, leaving EMACS in the computer and executing another command
shell. Most systems would allow you to return to EMACS with the "exit" command.
On some systems, mainly advanced versions of UNIX, you can direct EMACS __ ____ ________ ______ ________ ________ __ _____ ___ ___ ______ _____
to "go into the background" with the ^XD suspend-emacs command. This places __ ___ ____ ___ ___________ ____ ___ ^XD _____________ ________ ____ ______ ___
EMACS in the background returning you to the original command shell. EMACS can _____ __ ___ __________ _________ ___ __ ___ ________ _______ ______ _____ ___
then be returned to at any time with the "fg" foreground command. ____ __ ________ __ __ ___ ____ ____ ___ ____ __________ ________
44 Access to the Outside World MicroEMACS Reference Manual
Chapter 11 Summary Chapter 11 Summary
In Chapter 11 introduced different ways to access the computers shell or
command processor from within EMACS. The commands in the following table were